package cn.stylefeng.guns.modular.business.frequency.appmessage.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.appmessage.service.AppMessageService;
import cn.stylefeng.guns.modular.business.frequency.appmessage.model.param.AppMessageParam;

import javax.annotation.Resource;

/**
 * 后台——系统消息表
 *
 * @author: liwenlong
 * @date: 2023-02-23
 */
@RestController
public class AppMessageController {

    @Resource
    private AppMessageService appMessageService;

    /**
     * 分页查询系统消息表
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/page")
    @BusinessLog(title = "系统消息表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(@RequestBody  AppMessageParam appMessageParam) {
        return new SuccessResponseData(appMessageService.page(appMessageParam));
    }

    /**
     * 获取全部系统消息表
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/list")
    @BusinessLog(title = "系统消息表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(@RequestBody  AppMessageParam appMessageParam) {
        return new SuccessResponseData(appMessageService.list(appMessageParam));
    }

    /**
     * 查看详情系统消息表
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/detail")
    @BusinessLog(title = "系统消息表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@RequestBody @Validated(AppMessageParam.detail.class) AppMessageParam appMessageParam) {
        return new SuccessResponseData(appMessageService.detail(appMessageParam.getId()));
    }

    ///**
    // * 添加系统消息表
    // *
    // * @author liwenlong
    // * @date 2023-02-23
    // */
    //@PostMapping("/appMessage/add")
    //@BusinessLog(title = "系统消息表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    //public ResponseData add(@RequestBody @Validated(AppMessageParam.add.class) AppMessageParam appMessageParam) {
    //    appMessageService.add(appMessageParam);
    //    return new SuccessResponseData();
    //}

    /**
     * 删除系统消息表
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/delete")
    @BusinessLog(title = "系统消息表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(AppMessageParam.delete.class) AppMessageParam appMessageParam) {
        appMessageService.delete(appMessageParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑系统消息表
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/edit")
    @BusinessLog(title = "系统消息表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(AppMessageParam.edit.class) AppMessageParam appMessageParam) {
        appMessageService.edit(appMessageParam);
        return new SuccessResponseData();
    }


    /**
     * 发布
     *
     * @author liwenlong
     * @date 2023-02-23
     */
    @PostMapping("/appMessage/publish")
    @BusinessLog(title = "系统消息表_发布", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData publish(@RequestBody AppMessageParam appMessageParam) {
        appMessageService.publish(appMessageParam);
        return new SuccessResponseData();
    }


}
